package cn.lzy.ioc;

import cn.lzy.ioc.entity.Cat;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description 演示 bean 标签的 id 和 name 用法
 * @Author lzy
 * @Date 2023/9/1 14:12
 * @Version
 **/
public class TestDemo02 {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
//        Cat cat = (Cat) context.getBean("cat");
//        System.out.println("cat = " + cat);
//
//        Cat cat3 = context.getBean("cat3", Cat.class);
//        System.out.println("cat3 = " + cat3);
//
//        Cat cat8 = context.getBean("cn.lzy.ioc.entity.Cat", Cat.class);
//        System.out.println("cat8 = " + cat8);

        Cat cat0 = (Cat) context.getBean("cn.lzy.ioc.entity.Cat#0");
        Cat cat1 = (Cat) context.getBean("cn.lzy.ioc.entity.Cat#1");
        Cat cat2 = (Cat) context.getBean("cn.lzy.ioc.entity.Cat#2");
        System.out.println("cat0 = " + cat0);
        System.out.println("cat1 = " + cat1);
        System.out.println("cat2 = " + cat2);
    }
}
